package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IHomeService;
import com.mall.shopping.dto.HomePageResponse;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qugr
 * @create 2020-07-11 11:36
 */
@Slf4j
@RestController
@RequestMapping("/shopping")
public class HomePageController {

    @Reference(timeout = 3000,check = false)
    IHomeService homeService;

    @Anoymous
    @GetMapping("/homepage")
    public ResponseData getHomepage() {
        HomePageResponse response = homeService.homepage();
        if (response.getCode().equals(SysRetCodeConstants.SUCCESS.getCode())) {
            return new ResponseUtil<>().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil<>().setErrorMsg(response.getMsg());
    }
}
